package com.xish.api.shop;

import com.xish.api.shop.form.ShopEditForm;
import com.xish.util.MediaType;
import com.xish.view.json.Common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
public class ShopController {

    @Autowired
    private ShopFormParser parser;

    @Autowired
    private ShopService shopService;

    @RequestMapping(value = "/shop/edit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON)
    public Common edit(HttpServletRequest request) {
        Map<String, Object> data = new HashMap<>();
        Common common = new Common();

        ShopEditForm form = parser.parseShopEditForm(request);
        String top_session = "";
        shopService.edit(form,top_session);

        return common;
    }

}
